<template>
  <ul class="todo-main">
    <todo-item
      @delTodo="delTodo"
      @change="change"
      v-for="todo in todos"
      :key="todo.id"
      :todo="todo"
    ></todo-item>
  </ul>
</template>

<script setup lang="ts">
defineProps<{ todos: Todo[] }>()
const emit = defineEmits<{
  (e: 'delTodo', id: number): void
  (e: 'change', id: number, isDone: boolean): void
}>()
import type { Todo } from '../types/todo'
import TodoItem from './TodoItem.vue'

const delTodo = (id: number): void => {
  emit('delTodo', id)
}

const change = (id: number, isDone: boolean): void => {
  emit('change', id, isDone)
}
</script>

<style scoped>
/*main*/
.todo-main {
  margin-left: 0px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 0px;
}

.todo-empty {
  height: 40px;
  line-height: 40px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding-left: 5px;
  margin-top: 10px;
}
</style>
